home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Graphics Samples / Getting Started w⁄GX ƒ / Getting Started GX - misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-15  |  5.5 KB  |  252 lines  |  [TEXT/KAHL]

  1. /**
  2.  --
  3.  --        App:        Getting Started w/QD GX (WWDC)
  4.  --
  5.  -- 
  6.  --        Version:    1.0     4/93:    added all of the calls required to support the "Getting 
  7.  --                                    Started with QuickDraw™ GX" session at the WWDC '93     
  8.  --
  9.  --                            8/93:    updated file to work with the ß2 "GXified" interface files
  10.  --            
  11.  --                            4/96 bob    Updated #includes to support changed GX Library names.
  12.  --                                        Updated the note regarding the files needed to run.
  13.  --                                        Updated the copyright date.
  14.  --
  15.  --        File:        Getting Started GX - misc.c
  16.  --
  17.  --
  18.  --        Comments:    This file contains utility and menu handling routines.
  19.  --
  20.  --
  21.  --        Components:    Getting Started GX - main.c
  22.  --                    Getting Started GX - main.h
  23.  --                    Getting Started GX - shapes.c
  24.  --                    Getting Started GX - printing.c
  25.  --                    Getting Started GX - misc.c
  26.  --                    Getting Started QD GX.π.rsrc
  27.  --
  28.  --                    The file titled: "Getting Started GX - main.c" contains the code required to
  29.  --                    intialize and tear down the QuickDraw GX world, and the event loop.
  30.  --
  31.  --                    The file titled: "Getting Started GX - shapes.c" contains of the code used to 
  32.  --                    create and manipulate the shapes draw into the window.
  33.  --        
  34.  --                    The file titled: "Getting Started GX - printing.c" contains of the code used to 
  35.  --                    print the contents of  the window.
  36.  --        
  37.  --        
  38.  --        QuickDraw GX
  39.  --        Libraries
  40.  --        Used:        This application uses the following QuickDraw GX library code files:
  41.  --                    "ColorLibrary.c", "FontLibrary.c", "GraphicsDebugLibrary.c", "LayoutLibrary.c",
  42.  --                    "ShapeLibrary.c", "TransferModeLibrary.c", and "TransformLibrary.c".
  43.  --        
  44.  --        
  45.  --        Notes:        1) Print this file in landscape for the best results
  46.  --                    2) If you are using THINK C v5.x, I have added THINK markers to navigate the code.
  47.  --                    3) This code was adapted from the "Banana Jr." QuickDraw GX sample.
  48.  --
  49.  --
  50.  --        Author:        Pete "Luke" Alexander
  51.  --                    Developer Technical Support
  52.  --                    AppleLink: DEVSUPPORT
  53.  --
  54.  --        
  55.  --        ©1992 - 1996  Apple Computer, Inc. 
  56.  --        All rights reserved.
  57.  --
  58.  **/
  59.  
  60. #include <Desk.h>
  61. #include <Menus.h>
  62.  
  63.  
  64. #include <GXEnvironment.h>
  65. #include "GraphicsLibraries.h"
  66. #include <GXPrinting.h>
  67. #include "Getting Started GX - main.h"
  68.  
  69.  
  70. /*------ DoMenuCommand ---------------------------------------------------------------------------------------*/
  71. //
  72. //    This routine handles the dispatching of our menu requests.
  73. //
  74. void DoMenuCommand(long menuResult)
  75. {
  76.     short                menuID;
  77.     short                menuItem;
  78.     Str255                daName;
  79.     OSErr                err;
  80.     gxDialogResult        result;
  81.     
  82.     menuID = menuResult >>16;
  83.     menuItem = menuResult & 0x0000ffff;
  84.     
  85.     switch (menuID)
  86.     {
  87.         case mApple:
  88.             switch (menuItem)
  89.             {
  90.                 case iAbout:        /* display About box */
  91.                     break;
  92.                 
  93.                 default:            /* handle DA selection */
  94.                     GetItem(GetMHandle(mApple), menuItem, daName);
  95.                     OpenDeskAcc(daName);
  96.                     break;
  97.             }
  98.             break;
  99.             
  100.             case mFile:
  101.                 switch (menuItem)
  102.                 {                        
  103.                     case iNew:
  104.                             /* create new window */
  105.                             
  106.                                 err = DoCreateNew();
  107.                         break;
  108.                                                 
  109.                     case iOpen:
  110.                             /* open saved window */
  111.                             
  112.                         break;
  113.                                                 
  114.                     case iClose:
  115.                             /* close front window */
  116.                             
  117.                                 DoDispose(FrontWindow());
  118.                         break;
  119.                                                 
  120.                     case iSave:
  121.                             /* save front window */
  122.                             
  123.                         break;
  124.                                                 
  125.                     case iPrintOne:
  126.                             /* perform print-one */
  127.                             
  128.                             err = DoPrintOneCopy(FrontWindow());
  129.                         break;
  130.  
  131.                     case iDocumentSetup:
  132.                             /* perform document setup */
  133.                             
  134.                                 HiliteMenu(0);
  135.                                 err = DoFormat(FrontWindow(), &result);
  136.                         break;
  137.     
  138.                     case iByPageSetup:
  139.                             /* perform by page setup */
  140.                                 HiliteMenu(0);
  141.                         break;
  142.                                                 
  143.                         
  144.                     case iPrint:
  145.                             /* perform print */
  146.                             
  147.                                 HiliteMenu(0);
  148.                                 err = DoPrinting(FrontWindow());
  149.                         break;
  150.  
  151.                     case iQuit:
  152.                         gQuitting = true;
  153.                         break;
  154.                 }
  155.                 break;
  156.                 
  157.             case mEdit:
  158.                 break;
  159.                 
  160.             case mGraphics:
  161.                 switch (menuItem)
  162.                 {                        
  163.                     case iCreateABlackRectangle:
  164.                         CreateABlackRectangle (FrontWindow());
  165.                         break;
  166.                         
  167.                     case iColorTheRectangle:
  168.                         ColorTheRectangle (FrontWindow());
  169.                         break;
  170.                         
  171.                     case iCreateAQ:
  172.                         CreateAQ(FrontWindow());
  173.                         break;
  174.                         
  175.                     case iOutlineTheQ:
  176.                         OutlineTheQ(FrontWindow());
  177.                         break;
  178.                         
  179.                     case iCreateAD:
  180.                         CreateAD(FrontWindow());
  181.                         break;
  182.                         
  183.                     case iCreateAG:
  184.                         CreateAG(FrontWindow());
  185.                         break;
  186.                         
  187.                     case iCreateAX:
  188.                         CreateAX(FrontWindow());
  189.                         break;
  190.                 }
  191.                 break;
  192.                 
  193.             case mTypography:
  194.                 switch (menuItem)
  195.                 {                        
  196.                     case iCreateLayout:
  197.                         CreateNewLayoutShape (FrontWindow());
  198.                         break;
  199.                         
  200.                     case iAddKanjiToLayout:
  201.                         AddKanjiToLayout (FrontWindow());
  202.                         break;
  203.                         
  204.                     case iPerspectLayout:
  205.                         PerspectLayout(FrontWindow());
  206.                         break;
  207.                 }
  208.                 break;
  209.  
  210.     }
  211.     HiliteMenu(0);
  212. }
  213.  
  214.  
  215.  
  216. /*------ GetDocShape ---------------------------------------------------------------------------------*/
  217. //
  218. //    This utility routine returns the page shape (contents) attached to a window's document.
  219. //
  220. gxShape GetDocShape(WindowPtr wind)
  221. {
  222.     TH_Doc    doc;
  223.     gxShape    docPage = nil;
  224.  
  225.     if (wind)
  226.     {
  227.         doc = (TH_Doc) GetWRefCon(wind);
  228.         docPage = (*doc)->docPage;
  229.     }
  230.     
  231.     return docPage;
  232. }
  233.  
  234.  
  235. /*------ GetDocJob -----------------------------------------------------------------------------------*/
  236. //
  237. //    This utility routine returns the print job attached to a window's document.
  238. //
  239. gxJob GetDocJob(WindowPtr wind)
  240. {
  241.     TH_Doc    doc;
  242.     gxJob    docJob = nil;
  243.  
  244.     if (wind)
  245.     {
  246.         doc = (TH_Doc) GetWRefCon(wind);
  247.         docJob = (*doc)->docJob;
  248.     }
  249.     
  250.     return docJob;
  251. }
  252.